var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, o) {
    var i, r = arguments.length, a = r < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(t, e, n, o); else for (var s = t.length - 1; 0 <= s; s--) (i = t[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(e, n, a) : i(e, n)) || a);
    return 3 < r && a && Object.defineProperty(e, n, a), a;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("AudioManager"), s = e("UIManager"), c = e("WebManager"), l = cc._decorator, d = l.ccclass, u = l.property, p = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.sprite = null, t.lowSpriteFrame = null, t.heightSpriteFrame = null, t.rank = 0, 
        t.box = null, t.type = 0, t.isEffect = !0, t.isDestory = !1, t.isOpen = !1, t;
    }
    return i(t, e), t.prototype.onClickBox = function() {
        var e, n, o = this;
        r.default.getInstance().playAudio("宝箱原地打开音效-新", 2), this.isEffect || this.isDestory || (this.unschedule(this.doOpen), 
        this.isDestory = !0, e = s.default.getInstance().getPnl("start"), (n = e.getCombine().getComponent(sp.Skeleton)).node.parent = this.node, 
        n.node.active = !0, n.setAnimation(0, "animation", !1), n.setCompleteListener(function() {
            switch (o.type) {
              case 0:
                c.default.getInstance().sentLog("点击首页普通装备箱"), o.box && !isNaN(o.rank) && (o.box.equip = null, 
                (t = s.default.getInstance().getPnl("start")).appendItem(o.rank, o.box), t.updateMatrix());
                break;

              case 1:
                var t;
                c.default.getInstance().sentLog("点击首页高级装备箱"), o.box && !isNaN(o.rank) && (o.box.equip = null, 
                (t = s.default.getInstance().getPnl("start")).appendItem(o.rank, o.box), t.updateMatrix()), 
                s.default.getInstance().loadPopPnl("equip", {
                    rank: o.rank
                });
            }
            n.clearTracks(), n.node.active = !1, e.combinePool.put(n.node), o.node.destroy();
        }));
    }, t.prototype.start = function() {
        this.isOpen && this.scheduleOnce(this.doOpen, 5);
    }, t.prototype.init = function(t) {
        var e = this;
        if (t.type) switch (this.type = t.type, this.type) {
          case 0:
            this.sprite.spriteFrame = this.lowSpriteFrame;
            break;

          case 1:
            this.sprite.spriteFrame = this.heightSpriteFrame;
        }
        t.rank && (this.rank = t.rank), t.box && (this.box = t.box, (this.box.equip = this).node.setPosition(cc.v2(0, 800)), 
        cc.tween(this.node).by(.5, {
            position: cc.v3(0, -800)
        }).by(.1, {
            position: cc.v3(0, 20)
        }).by(.1, {
            position: cc.v3(0, -20)
        }).call(function() {
            e.isEffect = !1;
        }).start(), this.node.parent = this.box.node), this.isOpen = !0;
    }, t.prototype.doOpen = function() {
        var t = this;
        r.default.getInstance().playAudio("宝箱原地打开音效-新"), this.isDestory = !0;
        var e = s.default.getInstance().getPnl("start"), n = e.getCombine().getComponent(sp.Skeleton);
        n.node.parent = this.node, n.node.active = !0, n.setAnimation(0, "animation", !1), 
        n.setCompleteListener(function() {
            t.box.equip = null, e.appendItem(t.rank, t.box), e.updateMatrix(), e.checkAllEggs(), 
            n.clearTracks(), n.node.active = !1, e.combinePool.put(n.node), t.node.destroy();
        });
    }, a([ u(cc.Sprite) ], t.prototype, "sprite", void 0), a([ u(cc.SpriteFrame) ], t.prototype, "lowSpriteFrame", void 0), 
    a([ u(cc.SpriteFrame) ], t.prototype, "heightSpriteFrame", void 0), a([ d ], t);
}(cc.Component);

n.default = p;